﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using ByteSite.Common;

namespace ByteSite.BLL
{
    /// <summary>
    ///article_comment
    /// </summary>
    public partial class article_comment
    {
        private readonly Entitys.sysconfig sysConfig = new BLL.sysconfig().loadConfig();//获得系统配置信息
        private readonly DAL.Data data;

        public article_comment()
        {
            data = new DAL.Data();
        }

        #region 基本方法================================
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int id)
        {
            return data.Exists<Entitys.dt_article_comment>(id);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Entitys.dt_article_comment model)
        {
            return data.Insert(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Entitys.dt_article_comment model)
        {
            return data.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int id)
        {
            return data.Delete<Entitys.dt_article_comment>(id);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Entitys.dt_article_comment GetModel(int id)
        {
            return data.Get<Entitys.dt_article_comment>(id);
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public List<Entitys.dt_article_comment> GetList(int Top, string strWhere, string filedOrder)
        {
            return data.List<Entitys.dt_article_comment>(Top, strWhere, filedOrder);
        }

        /// <summary>
        /// 获得查询分页数据
        /// </summary>
        public List<Entitys.dt_article_comment> GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return data.List<Entitys.dt_article_comment>(pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }
        #endregion

        #region 扩展方法================================
        /// <summary>
        /// 返回数据总数(AJAX分页用到)
        /// </summary>
        public int GetCount(Expression<Func<Entitys.dt_article_comment, bool>> whereExpression)
        {
            return data.Count<Entitys.dt_article_comment>(whereExpression);
        }
        public int GetCount(string strWhere)
        {
            return data.Count<Entitys.dt_article_comment>(strWhere);
        }

        /// <summary>
        /// 修改一列数据
        /// </summary>
        public void UpdateField(Expression<Func<Entitys.dt_article_comment, Entitys.dt_article_comment>> expression, Expression<Func<Entitys.dt_article_comment, bool>> whereExpression)
        {
            data.UpdateColumns<Entitys.dt_article_comment>(expression, whereExpression);
        }
        #endregion
    }
}